package cn.sciento.transfer.infra.chk.job;

import java.util.Map;
import org.apache.commons.lang3.exception.ExceptionUtils;
import cn.sciento.boot.scheduler.infra.annotation.JobHandler;
import cn.sciento.boot.scheduler.infra.enums.ReturnT;
import cn.sciento.boot.scheduler.infra.handler.IJobHandler;
import cn.sciento.boot.scheduler.infra.tool.SchedulerTool;
import cn.sciento.transfer.api.controller.v1.DataChkBatchController;
import cn.sciento.transfer.api.dto.DataChkBatchCreateDTO;
import org.springframework.beans.factory.annotation.Autowired;

@JobHandler("dataCheckJob")
public class DataCheckJob implements IJobHandler {
  @Autowired
  private DataChkBatchController dataChkBatchController;
  
  public ReturnT execute(Map<String, String> map, SchedulerTool tool) {
    DataChkBatchCreateDTO dataChkBatchCreateDTO = new DataChkBatchCreateDTO();
    dataChkBatchCreateDTO.setChkLevel("ALL");
    try {
      this.dataChkBatchController.create(dataChkBatchCreateDTO);
    } catch (Exception e) {
      tool.error(ExceptionUtils.getStackTrace(e));
      return ReturnT.FAILURE;
    } 
    return ReturnT.SUCCESS;
  }
}
